package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Workflow;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WorkflowDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "工作流名称")
    private String name;

    @ApiModelProperty(value = "工作流类型")
    private Integer type;

    private String jsonConfig;

    @ApiModelProperty(value = "0禁用,1开启")
    private Integer state;

    @ApiModelProperty(value = "是否默认：0否，1是")
    private Integer defaultOrNot;

    /**
     * 当前部门领导提交的表单：0 不免审，1免审
     */
    @ApiModelProperty(value = "免审:0,不免，1免审")
    private Integer exempt;

    @ApiModelProperty(value = "是否反审批： 0否 1是")
    private Integer isAnti;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;


    public WorkflowDTO() {}

    public WorkflowDTO(Workflow entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static WorkflowDTO convert(Workflow entity) {
        return new WorkflowDTO(entity);
    }

    public static List<WorkflowDTO> convertList(List<Workflow> list) {
        List<WorkflowDTO> resultList = new ArrayList<>();
        for (Workflow entity : list) {
            resultList.add(new WorkflowDTO(entity));
        }
        return resultList;
    }}
